package com.jeff.practice;

import java.util.ArrayList;
import java.util.List;

/**
 * 给定正整数,求其质因子
 *
 * @author yaojianfeng
 */
public class CalculatePrimeNumber {
    public static void main(String[] args) {

        int number = 179;
        List<Integer> factors = getPrimeFactors(number);
        for (int factor : factors) {
            System.out.print(factor + " ");
        }
    }

    public static List<Integer> getPrimeFactors(int number) {
        List<Integer> factors = new ArrayList<>();
        int divisor = 2;
        while (number > 1) {
            while (number % divisor == 0) {
                factors.add(divisor);
                number /= divisor;
            }
            divisor++;
        }
        return factors;
    }
}